商户流水接口

商户流水接口
master
siontion 6 months ago
parent 943fbccf38
commit 2539e64ffc

@ -5,6 +5,7 @@ import cc.yunxi.aspect.UserTypeAnnotation;
import cc.yunxi.common.domain.CommonResult; import cc.yunxi.common.domain.CommonResult;
import cc.yunxi.common.domain.PageDTO; import cc.yunxi.common.domain.PageDTO;
import cc.yunxi.common.utils.BeanUtils; import cc.yunxi.common.utils.BeanUtils;
import cc.yunxi.common.utils.WebUtils;
import cc.yunxi.domain.dto.UserDTO; import cc.yunxi.domain.dto.UserDTO;
import cc.yunxi.domain.dto.WxLoginDTO; import cc.yunxi.domain.dto.WxLoginDTO;
import cc.yunxi.domain.dto.ZSGLoginDTO; import cc.yunxi.domain.dto.ZSGLoginDTO;
@ -15,18 +16,27 @@ import cc.yunxi.domain.query.ClientQuery;
import cc.yunxi.domain.vo.client.ClientAccountRespVO; import cc.yunxi.domain.vo.client.ClientAccountRespVO;
import cc.yunxi.domain.vo.client.ClientRespVO; import cc.yunxi.domain.vo.client.ClientRespVO;
import cc.yunxi.domain.vo.client.ClientUpdateVO; import cc.yunxi.domain.vo.client.ClientUpdateVO;
import cc.yunxi.domain.vo.device.RecycleDeviceOpenDoorReqVO;
import cc.yunxi.domain.vo.device.RecycleDeviceRespVO;
import cc.yunxi.enums.UserTypeEnum; import cc.yunxi.enums.UserTypeEnum;
import cc.yunxi.service.IClientService; import cc.yunxi.service.IClientService;
import cc.yunxi.service.IRecycleDeviceService;
import cc.yunxi.service.impl.CommonService; import cc.yunxi.service.impl.CommonService;
import cc.yunxi.utils.UserContext; import cc.yunxi.utils.UserContext;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -45,7 +55,20 @@ import java.util.Map;
@Slf4j @Slf4j
public class EntranceController { public class EntranceController {
private final CommonService commonService; private static final String OPEN_API_URL = "https://dev-api.zsgai.com/open_api/open_door_for_devsn";
@Resource
private CommonService commonService;
@Resource
private IRecycleDeviceService deviceService;
@ApiOperation("回收柜二维码请求设备信息接口")
@RequestMapping("/dev_qr_code/wx9e638ba024ed7868")
public CommonResult<String> ZSG_QrCode_DeviceInfo(@RequestParam(name="devsn",required = true) String devSn) {
return CommonResult.success(devSn);
}
@ApiOperation("小智系统请求用户登录接口") @ApiOperation("小智系统请求用户登录接口")
@RequestMapping("/login_name") @RequestMapping("/login_name")
@ -55,4 +78,27 @@ public class EntranceController {
return CommonResult.success(zsgLoginDTO,"请求成功"); return CommonResult.success(zsgLoginDTO,"请求成功");
} }
@ApiOperation("回收柜设备状态上报")
@RequestMapping("/device_state")
public CommonResult<String> ZSG_DeviceState(HttpServletRequest request) throws Exception {
// 1. 参数解析处理
Map<String, String> dataMap = WebUtils.parseQueryString(request);
String listDoor = dataMap.remove("listDoor");
RecycleDeviceRespVO recycleDeviceRespVO = BeanUtils.copyBean(dataMap, RecycleDeviceRespVO.class);
if(StrUtil.isNotEmpty(listDoor)) {
JSONArray jsonArray = JSONUtil.parseArray(listDoor);
List<RecycleDeviceRespVO.RecycleDeviceDoorVO> deviceDoorVOList = BeanUtils.copyList(jsonArray, RecycleDeviceRespVO.RecycleDeviceDoorVO.class);
recycleDeviceRespVO.setListDoor(deviceDoorVOList);
}
log.info("recycleDeviceRespVO = {}", recycleDeviceRespVO);
deviceService.saveDeviceInfo(recycleDeviceRespVO);
return CommonResult.success("ok");
}
@SneakyThrows
@ApiOperation("开门")
@GetMapping("/open_door_for_devsn")
public CommonResult<String> ZSG_OpenDoor(@RequestBody RecycleDeviceOpenDoorReqVO recycleDeviceOpenDoorReqVO) {
// devUserId
return CommonResult.success("ok");
}
} }

@ -28,6 +28,8 @@ import org.apache.ibatis.annotations.Param;
public interface WalletMapper extends BaseMapper<EnterpriseWallet> { public interface WalletMapper extends BaseMapper<EnterpriseWallet> {
Page<EnterpriseWallet> queryPageByPhone(@Param("phone") String phone); Page<EnterpriseWallet> queryPageByPhone(@Param("phone") String phone);
String queryCompanyParentId(String companyId);
} }

@ -23,5 +23,7 @@ public interface IEnterpriseWalletService extends IService<EnterpriseWallet> {
Page<EnterpriseWallet> queryWalletByPage(WalletQuery walletQuery); Page<EnterpriseWallet> queryWalletByPage(WalletQuery walletQuery);
String queryCompanyParentId(String companyId);
} }

@ -31,6 +31,7 @@ import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.Date; import java.util.Date;
/** /**
@ -50,12 +51,22 @@ public class EnterpriseWalletServiceImpl extends ServiceImpl<WalletMapper, Enter
@Autowired @Autowired
private IBillRuleService billRuleService; private IBillRuleService billRuleService;
@Override
@Transactional(rollbackFor = Exception.class)
public String queryCompanyParentId(String companyId){
return walletMapper.queryCompanyParentId(companyId);
}
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public String addWallet(WalletVO walletVO) { public String addWallet(WalletVO walletVO) {
EnterpriseWallet enterpriseWallet = BeanUtils.copyBean(walletVO, EnterpriseWallet.class); EnterpriseWallet enterpriseWallet = BeanUtils.copyBean(walletVO, EnterpriseWallet.class);
enterpriseWallet.setCode(this.getNumber("LS")); enterpriseWallet.setCode(this.getNumber());
enterpriseWallet.setPhoto(formatPhoto(enterpriseWallet.getPhoto()));
enterpriseWallet.setFile(formatFile(enterpriseWallet.getFile()));
String companyParentId = walletMapper.queryCompanyParentId(enterpriseWallet.getCompanyId());
enterpriseWallet.setOrganizeJsonId(String.format("[\"%s\",\"%s\"]",companyParentId,enterpriseWallet.getCompanyId()));
// 返回内容 // 返回内容
walletMapper.insert(enterpriseWallet); walletMapper.insert(enterpriseWallet);
@ -74,7 +85,8 @@ public class EnterpriseWalletServiceImpl extends ServiceImpl<WalletMapper, Enter
return this.page(pageDO, wrapperX); return this.page(pageDO, wrapperX);
} }
private String getNumber(String enCode) { private String getNumber() {
String enCode = "LS";
StringBuilder strNumber = new StringBuilder(); StringBuilder strNumber = new StringBuilder();
LambdaQueryWrapper<BillRule> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<BillRule> wrapper = new LambdaQueryWrapper<>();
@ -113,6 +125,25 @@ public class EnterpriseWalletServiceImpl extends ServiceImpl<WalletMapper, Enter
return strNumber.toString(); return strNumber.toString();
} }
private String formatPhoto(String photo){
if(StrUtil.isEmpty(photo)){
return "";
}
String fileName = photo.substring(photo.lastIndexOf("/")+1,photo.length());
String urlPath = photo.substring(photo.lastIndexOf("/upload"),photo.length());
return String.format("[{\"name\":\"%s\",\"url\":\"%s\",\"fileId\":\"%s\"}]",fileName,urlPath,fileName);
}
private String formatFile(String file){
if(StrUtil.isEmpty(file)){
return "";
}
String fileName = file.substring(file.lastIndexOf("/")+1,file.length());
String fileExt = file.substring(file.lastIndexOf(".")+1,file.length());
String urlPath = file.substring(file.lastIndexOf("/upload"),file.length());
return String.format("[{\"fileSize\":0,\"fileExtension\":\"%s\",\"name\":\"%s\",\"url\":\"%s\",\"fileId\":\"%s\"}]",fileExt,fileName,urlPath,fileName);
}
} }

@ -10,4 +10,8 @@
where c.f_mobile_phone=#{phone}; where c.f_mobile_phone=#{phone};
</select> </select>
<select id="queryCompanyParentId" resultType="String">
SELECT f_parent_id as id FROM base_organize where f_id=#{companyId} limit 1;
</select>
</mapper> </mapper>

Loading…
Cancel
Save