Merge remote-tracking branch 'origin/cell-v9-check-faceModel-smartSchool-v2' into cell-v9-check-faceModel-smartSchool-v2
# Conflicts: # shapelight-admin/src/main/java/net/shapelight/modules/mobile/entity/MobilePackageOrder.java # shapelight-admin/src/main/java/net/shapelight/modules/mobile/mapper/MobileCallLogsMapper.java # shapelight-admin/src/main/java/net/shapelight/modules/mobile/mapper/MobileDeviceGroupMapper.java # shapelight-admin/src/main/java/net/shapelight/modules/mobile/mapper/MobileDeviceMapper.java # shapelight-admin/src/main/java/net/shapelight/modules/mobile/mapper/MobilePackageMapper.java # shapelight-admin/src/main/java/net/shapelight/modules/mobile/mapper/MobilePackageOrderMapper.java
This commit is contained in:
commit
f63b4fc8ba
|
@ -94,6 +94,8 @@ public class GlobalValue {
|
||||||
private String wxSecret;
|
private String wxSecret;
|
||||||
@Value("${global.wx.url}")
|
@Value("${global.wx.url}")
|
||||||
private String wxUrl;
|
private String wxUrl;
|
||||||
|
@Value("${global.wx.mchid}")
|
||||||
|
private String mchid;
|
||||||
|
|
||||||
@Value("${global.app.key}")
|
@Value("${global.app.key}")
|
||||||
private String appKey;
|
private String appKey;
|
||||||
|
|
|
@ -0,0 +1,111 @@
|
||||||
|
package net.shapelight.modules.appparent.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
|
import io.swagger.annotations.ApiImplicitParams;
|
||||||
|
import net.shapelight.common.config.GlobalValue;
|
||||||
|
import net.shapelight.common.utils.IpUtils;
|
||||||
|
import net.shapelight.common.utils.SnowflakeIdWorker;
|
||||||
|
import net.shapelight.modules.app.annotation.Login;
|
||||||
|
import net.shapelight.modules.app.annotation.LoginUser;
|
||||||
|
import net.shapelight.modules.fegin.OpFeignClient;
|
||||||
|
import net.shapelight.modules.mobile.entity.MobilePackage;
|
||||||
|
import net.shapelight.modules.mobile.entity.MobilePackageOrder;
|
||||||
|
import net.shapelight.modules.mobile.service.MobilePackageOrderService;
|
||||||
|
import net.shapelight.modules.mobile.service.MobilePackageService;
|
||||||
|
import net.shapelight.modules.ten.entity.TenParent;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.temporal.ChronoUnit;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/wx")
|
||||||
|
public class AppParentWxController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
MobilePackageOrderService orderService;
|
||||||
|
@Autowired
|
||||||
|
MobilePackageService packageService;
|
||||||
|
@Autowired
|
||||||
|
GlobalValue globalValue;
|
||||||
|
@Qualifier("net.shapelight.modules.fegin.OpFeignClient")
|
||||||
|
@Autowired
|
||||||
|
private OpFeignClient opFeignClient;
|
||||||
|
|
||||||
|
@Login
|
||||||
|
@PostMapping("创建订单")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name="openId",value = "客户唯一标识",paramType = "query",dataType = "String",required = true),
|
||||||
|
@ApiImplicitParam(name="package_id",value = "套餐ID",paramType = "query",dataType = "String",required = true),
|
||||||
|
})
|
||||||
|
public String createOrder(@LoginUser TenParent parent, @RequestParam Map<String, Object> params) {
|
||||||
|
MobilePackage mobilePackage = packageService.getById(params.get("package_id").toString());
|
||||||
|
MobilePackageOrder packageOrder = new MobilePackageOrder();
|
||||||
|
Long id = new SnowflakeIdWorker().nextId();
|
||||||
|
packageOrder.setOrderId(id);
|
||||||
|
packageOrder.setPackageId(mobilePackage.getPackageId());
|
||||||
|
packageOrder.setParentId(parent.getId());
|
||||||
|
packageOrder.setPayment(mobilePackage.getPrice().multiply(mobilePackage.getDiscount()));
|
||||||
|
packageOrder.setPayStatus(0);
|
||||||
|
Date currentDate = new Date();
|
||||||
|
if(mobilePackage.getEffectType().equals(0)) {
|
||||||
|
// 获取当前时间
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.setTime(currentDate);
|
||||||
|
packageOrder.setEffectiveDate(currentDate);
|
||||||
|
packageOrder.setStatus(1);
|
||||||
|
calendar.add(Calendar.MONTH, 1);
|
||||||
|
Date result = calendar.getTime();
|
||||||
|
packageOrder.setExpireTime(result);
|
||||||
|
} else {
|
||||||
|
// 获取当前时间
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.setTime(currentDate);
|
||||||
|
calendar.add(Calendar.MONTH, 1);
|
||||||
|
Date result = calendar.getTime();
|
||||||
|
packageOrder.setEffectiveDate(result);
|
||||||
|
packageOrder.setStatus(0);
|
||||||
|
calendar.add(Calendar.MONTH, 1);
|
||||||
|
packageOrder.setExpireTime(calendar.getTime());
|
||||||
|
}
|
||||||
|
if(mobilePackage.getPackageModel().equals(0)) {
|
||||||
|
packageOrder.setRemainderTime(mobilePackage.getDuration());
|
||||||
|
} else if (mobilePackage.getPackageModel().equals(1)) {
|
||||||
|
packageOrder.setRemainderCount(mobilePackage.getCallCount());
|
||||||
|
}
|
||||||
|
Map<String,Object> wxParams = new HashMap<>();
|
||||||
|
wxParams.put("appid",globalValue.getWxAppid());
|
||||||
|
wxParams.put("mchid",globalValue.getMchid());
|
||||||
|
wxParams.put("description",mobilePackage.getPackageName());
|
||||||
|
wxParams.put("out_trade_no",packageOrder.getOrderId());
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.setTime(currentDate);
|
||||||
|
calendar.add(Calendar.SECOND, 30);
|
||||||
|
wxParams.put("time_expire",calendar.getTime());
|
||||||
|
wxParams.put("attach",packageOrder.getOrderId());
|
||||||
|
wxParams.put("notify_url", IpUtils.getHostIp()+"/cell/wx/pay");
|
||||||
|
wxParams.put("goods_tag","xg");
|
||||||
|
wxParams.put("support_fapiao",true);
|
||||||
|
Map<String,Object> amount = new HashMap<>();
|
||||||
|
amount.put("total",packageOrder.getPayment().intValue());
|
||||||
|
amount.put("currency","CNY");
|
||||||
|
wxParams.put("amount",amount);
|
||||||
|
Map<String,Object> payer = new HashMap<>();
|
||||||
|
payer.put("openid",params.get("openId").toString());
|
||||||
|
wxParams.put("payer",payer);
|
||||||
|
JSONObject jsonObject = opFeignClient.createOrder(wxParams);
|
||||||
|
return jsonObject.getString("prepay_id");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -75,6 +75,10 @@ public interface OpFeignClient {
|
||||||
JSONObject getLicenseDeviceInfo(@RequestBody Map<String,Object> params);
|
JSONObject getLicenseDeviceInfo(@RequestBody Map<String,Object> params);
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("v3/pay/transactions/jsapi")
|
||||||
|
JSONObject createOrder(@RequestBody Map<String,Object> params);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,6 +62,11 @@ public class OpHystrix implements FallbackFactory<OpFeignClient> {
|
||||||
public JSONObject getLicenseDeviceInfo(Map<String, Object> params) {
|
public JSONObject getLicenseDeviceInfo(Map<String, Object> params) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JSONObject createOrder(Map<String, Object> params) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,10 +76,8 @@ public class MobilePackage implements Serializable {
|
||||||
/**
|
/**
|
||||||
* 套餐模式
|
* 套餐模式
|
||||||
*/
|
*/
|
||||||
@Size(max= 10,message="编码长度不能超过10")
|
|
||||||
@ApiModelProperty("套餐模式")
|
@ApiModelProperty("套餐模式")
|
||||||
@Length(max= 10,message="编码长度不能超过10")
|
private Integer packageModel;
|
||||||
private String packageModel;
|
|
||||||
/**
|
/**
|
||||||
* 折扣
|
* 折扣
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -109,6 +109,7 @@ global:
|
||||||
appid: wx313273bb23519704
|
appid: wx313273bb23519704
|
||||||
secret: a9162ffebee8e9892418bb78d86d7a80
|
secret: a9162ffebee8e9892418bb78d86d7a80
|
||||||
url: https://api.weixin.qq.com/
|
url: https://api.weixin.qq.com/
|
||||||
|
mchid: 1684613818
|
||||||
tcp_server:
|
tcp_server:
|
||||||
port: 8086
|
port: 8086
|
||||||
app:
|
app:
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<resultMap id="BaseResultMap" type="net.shapelight.modules.mobile.entity.MobilePackage">
|
<resultMap id="BaseResultMap" type="net.shapelight.modules.mobile.entity.MobilePackage">
|
||||||
<id property="packageId" column="package_id" jdbcType="BIGINT"/>
|
<id property="packageId" column="package_id" jdbcType="BIGINT"/>
|
||||||
<result property="packageName" column="package_name" jdbcType="VARCHAR"/>
|
<result property="packageName" column="package_name" jdbcType="VARCHAR"/>
|
||||||
<result property="packageType" column="package_type" jdbcType="VARCHAR"/>
|
<result property="packageType" column="package_type" jdbcType="INTEGER"/>
|
||||||
<result property="price" column="price" jdbcType="DECIMAL"/>
|
<result property="price" column="price" jdbcType="DECIMAL"/>
|
||||||
<result property="duration" column="duration" jdbcType="INTEGER"/>
|
<result property="duration" column="duration" jdbcType="INTEGER"/>
|
||||||
<result property="callCount" column="call_count" jdbcType="INTEGER"/>
|
<result property="callCount" column="call_count" jdbcType="INTEGER"/>
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
<resultMap id="BaseResultMap" type="net.shapelight.modules.mobile.entity.MobilePackageOrder">
|
<resultMap id="BaseResultMap" type="net.shapelight.modules.mobile.entity.MobilePackageOrder">
|
||||||
<id property="orderId" column="order_id" jdbcType="BIGINT"/>
|
<id property="orderId" column="order_id" jdbcType="BIGINT"/>
|
||||||
<result property="personId" column="person_id" jdbcType="BIGINT"/>
|
<result property="parentId" column="person_id" jdbcType="BIGINT"/>
|
||||||
<result property="packageId" column="package_id" jdbcType="BIGINT"/>
|
<result property="packageId" column="package_id" jdbcType="BIGINT"/>
|
||||||
<result property="payment" column="payment" jdbcType="DECIMAL"/>
|
<result property="payment" column="payment" jdbcType="DECIMAL"/>
|
||||||
<result property="payTime" column="pay_time" jdbcType="TIMESTAMP"/>
|
<result property="payTime" column="pay_time" jdbcType="TIMESTAMP"/>
|
||||||
|
@ -15,7 +15,7 @@
|
||||||
<result property="remainderTime" column="remainder_time" jdbcType="INTEGER"/>
|
<result property="remainderTime" column="remainder_time" jdbcType="INTEGER"/>
|
||||||
<result property="remainderCount" column="remainder_count" jdbcType="INTEGER"/>
|
<result property="remainderCount" column="remainder_count" jdbcType="INTEGER"/>
|
||||||
<result property="status" column="status" jdbcType="TINYINT"/>
|
<result property="status" column="status" jdbcType="TINYINT"/>
|
||||||
<result property="personName" column="person_name" jdbcType="VARCHAR"/>
|
<result property="parentName" column="person_name" jdbcType="VARCHAR"/>
|
||||||
<result property="expireTime" column="expire_time" jdbcType="TIMESTAMP"/>
|
<result property="expireTime" column="expire_time" jdbcType="TIMESTAMP"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue