diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/CustomerController.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/CustomerController.java new file mode 100644 index 00000000..36294aec --- /dev/null +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/CustomerController.java @@ -0,0 +1,97 @@ +package cc.hiver.mall.controller; + +import cc.hiver.core.common.utils.ResultUtil; +import cc.hiver.core.common.vo.Result; +import cc.hiver.core.entity.User; +import cc.hiver.core.service.UserService; +import cc.hiver.mall.entity.Customer; +import cc.hiver.mall.service.mybatis.CustomerService; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +@Slf4j +@RestController +@Api(tags = "客户接口") +@RequestMapping(value = "/hiver/app/customer/") +@Transactional +public class CustomerController { + @Autowired + private CustomerService customerService; + + @Autowired + private UserService userService; + + @RequestMapping(value = "/save", method = RequestMethod.POST) + @ApiOperation(value = "新增客户") + public Result save(Customer customer) { + + String encryptPass = new BCryptPasswordEncoder().encode(customer.getPassword()); + customer.setPassword(encryptPass); + boolean result = customerService.save(customer); + User user = new User(); + user.setUsername(customer.getName()); + user.setAddress(customer.getAddress()); + user.setType(2);//客户 + user.setMobile(customer.getPhone()); + user.setPassword(encryptPass); + userService.save(user); + if(result) { + return ResultUtil.success("添加成功"); + } else { + return ResultUtil.error("添加失败"); + } + } + +// @RequestMapping(value = "/edit", method = RequestMethod.POST) +// @ApiOperation(value = "根据客户id修改客户") +// public Result edit(Customer customer) { +// +// boolean result = customerService.updateById(customer); +// if(result) { +// return ResultUtil.success("修改成功"); +// } else { +// return ResultUtil.error("修改失败"); +// } +// } + + @RequestMapping(value = "/delById", method = RequestMethod.POST) + @ApiOperation(value = "根据id删除客户") + public Result delete(Customer customer) { + boolean result = customerService.removeById(customer); + if(result) { + return ResultUtil.success("删除成功"); + } else { + return ResultUtil.error("删除失败"); + } + } + + + @RequestMapping(value = "/list", method = RequestMethod.GET) + @ApiOperation(value = "查询客户列表") + public Result list() { + QueryWrapper queryWrapper = new QueryWrapper<>(); + List list = customerService.list(queryWrapper); + return new ResultUtil>().setData(list); + } + + @RequestMapping(value = "/listByName", method = RequestMethod.GET) + @ApiOperation(value = "根据客户名称查询客户列表") + public Result listByName(String name) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.like("name",name); + List list = customerService.list(queryWrapper); + return new ResultUtil>().setData(list); + } + + +} diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ReturnCommissionController.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ReturnCommissionController.java index 6fc29835..9db1d6f0 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ReturnCommissionController.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ReturnCommissionController.java @@ -8,6 +8,7 @@ import cc.hiver.mall.service.ShopService; import cc.hiver.mall.service.mybatis.ReturnCommissionService; import cc.hiver.mall.utils.AliPayUtil; import com.alipay.api.AlipayApiException; +import com.alipay.api.response.AlipayFundTransUniTransferResponse; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import io.swagger.annotations.Api; @@ -85,14 +86,24 @@ public class ReturnCommissionController { refuseWrapper.eq("id",id); //1.支付宝转至对方账户 ReturnCommission returnCommission = returnCommissionService.getById(id); + if(!"0".equals(returnCommission.getStatus())){ + return ResultUtil.error("该比佣金已处理。"); + } QueryWrapper shopQueryWrapper = new QueryWrapper<>(); Shop shop = shopService.get(returnCommission.getShopId()); String name = shop.getAliName();//支付宝户名(姓名) String phoneNumber = shop.getAliAccount();//支付宝账号(手机号) try { - com.alipay.api.domain.Result payResult = AliPayUtil.pay(phoneNumber, name, returnCommission.getCommission().toString(), id); - refuseWrapper.set("status","1"); - aliResult = "支付宝转账成功"; + AlipayFundTransUniTransferResponse payResult = AliPayUtil.pay(phoneNumber, name, returnCommission.getCommission().toString(), id); + if("SUCCESS".equals(payResult.getStatus())){ + refuseWrapper.set("status","1"); + aliResult = "支付宝转账成功"; + }else { + refuseWrapper.set("status","2"); + refuseWrapper.set("fail_message","支付宝转账失败"); + refuseWrapper.set("remark",payResult.getSubMsg()); + aliResult = "支付宝转账失败"; + } } catch (AlipayApiException e) { refuseWrapper.set("status","2"); refuseWrapper.set("fail_message","支付宝转账失败"); diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/CustomerMapper.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/CustomerMapper.java index 5e7c2021..7f39cbc7 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/CustomerMapper.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/CustomerMapper.java @@ -2,11 +2,14 @@ package cc.hiver.mall.dao.mapper; import cc.hiver.mall.entity.Customer; import cc.hiver.mall.entity.CustomerExample; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; +import org.springframework.stereotype.Repository; import java.util.List; - -public interface CustomerMapper { +@Repository +public interface CustomerMapper extends BaseMapper { long countByExample(CustomerExample example); int deleteByExample(CustomerExample example); diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/Customer.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/Customer.java index 0bdf6e0e..f62a7a5e 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/Customer.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/Customer.java @@ -43,6 +43,9 @@ public class Customer implements Serializable { @ApiModelProperty(value = "县区") private String area; + @ApiModelProperty(value = "商品id") + private String shopId; + private static final long serialVersionUID = 1L; public String getId() { @@ -149,6 +152,14 @@ public class Customer implements Serializable { this.area = area; } + public String getShopId() { + return shopId; + } + + public void setShopId(String shopId) { + this.shopId = shopId; + } + @Override public String toString() { StringBuilder sb = new StringBuilder(); @@ -168,6 +179,7 @@ public class Customer implements Serializable { sb.append(", province=").append(province); sb.append(", city=").append(city); sb.append(", area=").append(area); + sb.append(", shopId=").append(shopId); sb.append(", serialVersionUID=").append(serialVersionUID); sb.append("]"); return sb.toString(); diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/CustomerExample.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/CustomerExample.java index db913a08..4b7a8c8a 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/CustomerExample.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/CustomerExample.java @@ -984,6 +984,76 @@ public class CustomerExample { addCriterion("area not between", value1, value2, "area"); return (Criteria) this; } + + public Criteria andShopIdIsNull() { + addCriterion("shop_id is null"); + return (Criteria) this; + } + + public Criteria andShopIdIsNotNull() { + addCriterion("shop_id is not null"); + return (Criteria) this; + } + + public Criteria andShopIdEqualTo(String value) { + addCriterion("shop_id =", value, "shopId"); + return (Criteria) this; + } + + public Criteria andShopIdNotEqualTo(String value) { + addCriterion("shop_id <>", value, "shopId"); + return (Criteria) this; + } + + public Criteria andShopIdGreaterThan(String value) { + addCriterion("shop_id >", value, "shopId"); + return (Criteria) this; + } + + public Criteria andShopIdGreaterThanOrEqualTo(String value) { + addCriterion("shop_id >=", value, "shopId"); + return (Criteria) this; + } + + public Criteria andShopIdLessThan(String value) { + addCriterion("shop_id <", value, "shopId"); + return (Criteria) this; + } + + public Criteria andShopIdLessThanOrEqualTo(String value) { + addCriterion("shop_id <=", value, "shopId"); + return (Criteria) this; + } + + public Criteria andShopIdLike(String value) { + addCriterion("shop_id like", value, "shopId"); + return (Criteria) this; + } + + public Criteria andShopIdNotLike(String value) { + addCriterion("shop_id not like", value, "shopId"); + return (Criteria) this; + } + + public Criteria andShopIdIn(List values) { + addCriterion("shop_id in", values, "shopId"); + return (Criteria) this; + } + + public Criteria andShopIdNotIn(List values) { + addCriterion("shop_id not in", values, "shopId"); + return (Criteria) this; + } + + public Criteria andShopIdBetween(String value1, String value2) { + addCriterion("shop_id between", value1, value2, "shopId"); + return (Criteria) this; + } + + public Criteria andShopIdNotBetween(String value1, String value2) { + addCriterion("shop_id not between", value1, value2, "shopId"); + return (Criteria) this; + } } public static class Criteria extends GeneratedCriteria { diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/CustomerService.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/CustomerService.java new file mode 100644 index 00000000..f2dd7749 --- /dev/null +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/CustomerService.java @@ -0,0 +1,8 @@ +package cc.hiver.mall.service.mybatis; + +import cc.hiver.mall.entity.Customer; +import cc.hiver.mall.entity.Product; +import com.baomidou.mybatisplus.extension.service.IService; + +public interface CustomerService extends IService { +} diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/CustomerServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/CustomerServiceImpl.java new file mode 100644 index 00000000..21029f67 --- /dev/null +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/CustomerServiceImpl.java @@ -0,0 +1,14 @@ +package cc.hiver.mall.serviceimpl.mybatis; + +import cc.hiver.mall.dao.mapper.CustomerMapper; +import cc.hiver.mall.dao.mapper.ProductMapper; +import cc.hiver.mall.entity.Customer; +import cc.hiver.mall.entity.Product; +import cc.hiver.mall.service.mybatis.CustomerService; +import cc.hiver.mall.service.mybatis.ProductService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +@Service +public class CustomerServiceImpl extends ServiceImpl implements CustomerService { +} diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/utils/AliPayUtil.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/utils/AliPayUtil.java index e71b3c8b..c62b0e0f 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/utils/AliPayUtil.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/utils/AliPayUtil.java @@ -18,7 +18,7 @@ import com.alipay.api.response.AlipayFundTransUniTransferResponse; public class AliPayUtil { - public static Result pay(String phoneNumber, String name, String transAmount, String orderNo) throws AlipayApiException { + public static AlipayFundTransUniTransferResponse pay(String phoneNumber, String name, String transAmount, String orderNo) throws AlipayApiException { //应用私钥 String privateKey = "MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCJ6viyMqpuBWZo0PXaf/RT+JpAbgT6vkREVrzkUBJ/XJstCaGUv/yi4y6Ndf4brms/wO2ue3x+EzMMF1LCk+E7JPU2u7Ruidj/4iMq2C2psAyQV1gmp2wrj5lQCy92oRJKhfG2CugvAUoD5CJi64nbD8eF2LMEksjMvKBUG5sQ6/utlUfTK2Sil76fbyNp7AbtiAcHI6WQ5v7HtkoF676rXvHLLA6qmUD04NeuFoBBr0Nyc42KPUNVl0JkUsDYHxzzIED34TcQ8y3Kw44s/tE+9ud5WRftV+bobf8dthHFsvGbohKbOlCDD/6sVsAaXEXJIMmu/ydi0DdxyUYLhLAfAgMBAAECggEAET3Xw2dEGScBq37cDWnLoKfGmOFoK/SXUjfJu30rItLv70xx78ekjLR8AGFM2CcQ71JuJE75vEUoL43G4d5c3Oj84s/Kebsv7qVVoiiOZNVGbNEOix6JDlUQZIpRb7IpODnQguKQLjgqCZx+lAFAJauuVNRHZP34rmeyX3FoDFBT1bWBMFcqbscFVyf83WToHFNY7KUxdK58AgJc5KSG1TADeYLk7qklP8+kX26SNJaM8qpfNFk0TupBb2/uQuCTK0JhE9VvnpLnOu8c67fs5x3RyX1bX/WGLrfwuJx2b3S9VRogJKvlCT/Keq3HOV2kahYMIUDbTAGrdZYJmaB6KQKBgQDskuy88QmRzbX7rJjdc1A1UQN/ASGQNqjCfFdybsrRFHSbXfybPDFw5cf1Bx6YQ9TAuzZ6lVvg/UOxykvjKvF4RFaR57XiklY5VhRsOA02D0WmmbNG8WwI9/wqj3AwORehCt9w29xZuuWmJVaxtd7ep74mNuNmR873bCc/JGe6IwKBgQCVPiy3kfl95/2JIzoirKf1MYw1yKMPg21tTePMN3CPTCXnRHXFr2Uo3KtUmtC8HfN1pesOj0FKGCEPYIW8H8NfokWwfmvG2vXjPoYUZrdICfSnifdXhTBiqlsJwDLZxYAjG3KiSPlcQ9fdRxf+a9Y+HNcWGh7Mm71+aaLtYph71QKBgEJB6CIG1CpM1gI11d539GfqV7NTasYMOPm3f3piQ1WJiBsXmK8VjbdT88vRgaUdolGUXW65tDDwXexGfziRh22qniBhKBTb7WBDlpa0oCaa4mQFuitNZHeilLKK1935r3+AHxJp0W4kJTuCS6ScDl6H1n63crrrs7CiTt+lX5PHAoGAOwVxrc9e+boLfHagASKC8eb8ajDEu9fgKMAK/LJYI3Ob8dATO3DX8scCQt1O+3Zk1/wb75Ab4++S83/ao8F0BJgqM1hryyLA53PMlrjgdu7pAHEBjm0v63Uvt7V45sLCoB+0wBVX+HMkJXB+PrHq8nl5XlZKI+Tblei09GhvoVkCgYBAc67rlq3yX1jGrtpNQwyu2RMUTZabqiAKO8AACPeDf9yp5KydyUyIV6g/F0DAv0d4cVrvai0eK1moG3LD5/+LARJ8QIvNLu3EJXfBRImRCT3UHd2UHIUFmqFCgZevhkt5DX2SpzXWaT0XnvbqkQ8ToP/aTjgL3xYhmMj/uGCbiQ=="; CertAlipayRequest alipayConfig = new CertAlipayRequest();//支付宝配置 @@ -49,15 +49,15 @@ public class AliPayUtil { model.setOrderTitle("软件返佣"); request.setBizModel(model); AlipayFundTransUniTransferResponse response = alipayClient.certificateExecute(request); - Result result = new Result(); - if (response.isSuccess()) { - result.setResultCode("1"); - result.setResultMessage("调用成功"); - } else { - result.setResultCode("0"); - result.setResultMessage(response.getSubMsg()); - } - return result; +// Result result = new Result(); +// if (response.isSuccess()) { +// result.setResultCode("1"); +// result.setResultMessage("调用成功"); +// } else { +// result.setResultCode("0"); +// result.setResultMessage(response.getSubMsg()); +// } + return response; } diff --git a/hiver-modules/hiver-mall/src/main/resources/mapper/CustomerMapper.xml b/hiver-modules/hiver-mall/src/main/resources/mapper/CustomerMapper.xml index f4194ae0..001cae5c 100644 --- a/hiver-modules/hiver-mall/src/main/resources/mapper/CustomerMapper.xml +++ b/hiver-modules/hiver-mall/src/main/resources/mapper/CustomerMapper.xml @@ -15,6 +15,7 @@ + @@ -76,7 +77,7 @@ id, create_by, create_time, del_flag, update_by, update_time, name, phone, address, - password, province, city, area + password, province, city, area, shop_id @@ -253,6 +260,9 @@ area = #{record.area,jdbcType=VARCHAR}, + + shop_id = #{record.shopId,jdbcType=VARCHAR}, + @@ -272,7 +282,8 @@ password = #{record.password,jdbcType=VARCHAR}, province = #{record.province,jdbcType=VARCHAR}, city = #{record.city,jdbcType=VARCHAR}, - area = #{record.area,jdbcType=VARCHAR} + area = #{record.area,jdbcType=VARCHAR}, + shop_id = #{record.shopId,jdbcType=VARCHAR} @@ -316,6 +327,9 @@ area = #{area,jdbcType=VARCHAR}, + + shop_id = #{shopId,jdbcType=VARCHAR}, + where id = #{id,jdbcType=VARCHAR} @@ -332,7 +346,8 @@ password = #{password,jdbcType=VARCHAR}, province = #{province,jdbcType=VARCHAR}, city = #{city,jdbcType=VARCHAR}, - area = #{area,jdbcType=VARCHAR} + area = #{area,jdbcType=VARCHAR}, + shop_id = #{shopId,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR} \ No newline at end of file