作者 shenhailong

钉钉小程序所需要接口

... ... @@ -2,11 +2,14 @@ package com.sunyo.energy.location.controller;
import com.sunyo.energy.location.controller.response.ResultJson;
import com.sunyo.energy.location.dao.LocationMapper;
import com.sunyo.energy.location.dao.USERSMapper;
import com.sunyo.energy.location.model.USERS;
import com.sunyo.energy.location.service.LocationService;
import com.sunyo.energy.location.service.WaterMeterService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
... ... @@ -31,11 +34,14 @@ public class UserPayController {
@Autowired
private LocationMapper locationMapper;
@Autowired
private USERSMapper usersMapper;
@ApiOperation(value = "查看缴费房间")
@RequestMapping("/list")
public List userPayList(@RequestParam(value = "roomNumber", required = false) String roomNumber) {
return locationService.userPayList(roomNumber);
return locationService.userPayList(roomNumber, 0);
}
@ApiOperation(value = "充值水费")
... ... @@ -60,15 +66,16 @@ public class UserPayController {
@ApiOperation(value = "钉钉小程序请求水电返回数据")
@PostMapping("/mincData")
public Map<String, Object> mincData(@RequestParam(value = "loginName", required = false) String loginName) {
Map<String, Object> map = new HashMap<>();
/**
* 查询该账号所绑定的水电编号
*/
return map;
public List mincData(@RequestParam(value = "userName", required = false) String userName,
@RequestParam(value = "mobile", required = false) String mobile) {
USERS users = usersMapper.findRoomNumber(mobile);
if (!StringUtils.isEmpty(users.getUsername())){
List list = locationService.userPayList(users.getUsername(), users.getUserId());
return list;
}else {
return null;
}
}
}
... ...
package com.sunyo.energy.location.dao;
import com.sunyo.energy.location.model.USERS;
import org.apache.ibatis.annotations.Param;
public interface USERSMapper {
int deleteByPrimaryKey(Integer userId);
... ... @@ -11,6 +12,8 @@ public interface USERSMapper {
USERS selectByPrimaryKey(Integer userId);
USERS findRoomNumber(@Param("mobile") String mobile);
int updateByPrimaryKeySelective(USERS record);
int updateByPrimaryKey(USERS record);
... ...
... ... @@ -4,6 +4,6 @@ import java.util.List;
public interface LocationService {
List userPayList(String roomNumber);
List userPayList(String roomNumber, int userId);
}
... ...
... ... @@ -9,7 +9,6 @@ import com.sunyo.energy.location.utils.Md5Utils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
... ...
... ... @@ -30,7 +30,7 @@ public class LocationServiceImp implements LocationService {
WaterMeterService waterMeterService;
@Override
public List userPayList(String roomNumber) {
public List userPayList(String roomNumber, int userId) {
try {
// 房间号如果为null 跳过
... ... @@ -53,6 +53,8 @@ public class LocationServiceImp implements LocationService {
distanceWaterMap.put("wmFmstate", realTime.getWmFmstate());
distanceWaterMap.put("wmLacc", realTime.getWmLacc());
distanceWaterMap.put("wmId", wmId);
distanceWaterMap.put("roomNumber", roomNumber);
distanceWaterMap.put("userId", userId);
list.add(distanceWaterMap);
}
/**
... ... @@ -66,6 +68,8 @@ public class LocationServiceImp implements LocationService {
eeMap.put("deviceId", energyInfoForRealTime.getDeviceId());
eeMap.put("balance", energyInfoForRealTime.getBalance());
eeMap.put("wmId", "");
eeMap.put("roomNumber", roomNumber);
eeMap.put("userId", userId);
list.add(eeMap);
}
}
... ...
... ... @@ -89,7 +89,7 @@ public class PayOrderImpl implements PayOrderService {
* @throws Exception
*/
@Override
@Scheduled(cron = "0 0 * * * ?")
// @Scheduled(cron = "0 0 * * * ?")
public void waterEleCount() throws Exception {
Map<String, Object> map = new HashMap<>();
// 水量
... ...
... ... @@ -4,7 +4,8 @@
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
<generatorConfiguration>
<!-- 数据库驱动:选择你的本地硬盘上面的数据库驱动包-->
<classPathEntry location="/Users/shenhailong/.m2/repository/mysql/mysql-connector-java/5.1.30/mysql-connector-java-5.1.30.jar"/>
<classPathEntry
location="/Users/shenhailong/.m2/repository/mysql/mysql-connector-java/5.1.30/mysql-connector-java-5.1.30.jar"/>
<!--<classPathEntry location="/Users/mrz/Documents/maven/ojdbc6.jar"/>-->
<context id="DB2Tables" targetRuntime="MyBatis3">
<commentGenerator>
... ... @@ -41,10 +42,13 @@
<property name="enableSubPackages" value="true"/>
</sqlMapGenerator>
<!-- 生成DAO的包名和位置-->
<javaClientGenerator type="XMLMAPPER" targetPackage="com.sunyo.energy.location.dao" targetProject="src/main/java">
<javaClientGenerator type="XMLMAPPER" targetPackage="com.sunyo.energy.location.dao"
targetProject="src/main/java">
<property name="enableSubPackages" value="true"/>
</javaClientGenerator>
<!-- 要生成的表 tableName是数据库中的表名或视图名 domainObjectName是实体类名-->
<table tableName="pay_response" domainObjectName="PayResponse" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="true"></table>
<table tableName="users" domainObjectName="Users" enableCountByExample="false"
enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false"
selectByExampleQueryId="true"></table>
</context>
</generatorConfiguration>
\ No newline at end of file
... ...
... ... @@ -28,6 +28,13 @@
from users
where user_id = #{userId,jdbcType=INTEGER}
</select>
<select id="findRoomNumber" resultMap="BaseResultMap" parameterType="java.lang.String">
select
<include refid="Base_Column_List"/>
from users where mobilePhone = #{mobile, jdbcType=VARCHAR} order by creatTime desc limit 0,1
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from users
where user_id = #{userId,jdbcType=INTEGER}
... ...