parent
80fbf4ae2a
commit
c7cf44ec80
@ -0,0 +1,24 @@ |
|||||||
|
package com.hai.service; |
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject; |
||||||
|
|
||||||
|
/** |
||||||
|
* @serviceName ApiOpenService.java |
||||||
|
* @author Sum1Dream |
||||||
|
* @version 1.0.0 |
||||||
|
* @Description // api开发接口
|
||||||
|
* @createTime 17:29 2022/6/10 |
||||||
|
**/ |
||||||
|
public interface ApiOpenService { |
||||||
|
|
||||||
|
/** |
||||||
|
* @Author Sum1Dream |
||||||
|
* @name createOrder.java |
||||||
|
* @Description // 充值预下单
|
||||||
|
* @Date 17:31 2022/6/10 |
||||||
|
* @Param [com.alibaba.fastjson.JSONObject] |
||||||
|
* @return com.alibaba.fastjson.JSONObject |
||||||
|
*/ |
||||||
|
JSONObject createOrder(JSONObject object); |
||||||
|
|
||||||
|
} |
@ -0,0 +1,58 @@ |
|||||||
|
package com.hai.service.impl; |
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject; |
||||||
|
import com.hai.common.exception.ErrorCode; |
||||||
|
import com.hai.common.exception.ErrorHelp; |
||||||
|
import com.hai.common.exception.SysCode; |
||||||
|
import com.hai.entity.ApiMerchants; |
||||||
|
import com.hai.entity.ApiOrderRecord; |
||||||
|
import com.hai.entity.ApiProduct; |
||||||
|
import com.hai.service.ApiMerchantsService; |
||||||
|
import com.hai.service.ApiOpenService; |
||||||
|
import com.hai.service.ApiOrderRecordService; |
||||||
|
import com.hai.service.ApiProductService; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
import org.springframework.transaction.annotation.Isolation; |
||||||
|
import org.springframework.transaction.annotation.Propagation; |
||||||
|
import org.springframework.transaction.annotation.Transactional; |
||||||
|
|
||||||
|
import javax.annotation.Resource; |
||||||
|
import java.util.HashMap; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
@Service("apiOpenService") |
||||||
|
public class ApiOpenServiceImpl implements ApiOpenService { |
||||||
|
|
||||||
|
@Resource |
||||||
|
private ApiOrderRecordService apiOrderRecordService; |
||||||
|
|
||||||
|
@Resource |
||||||
|
private ApiMerchantsService apiMerchantsService; |
||||||
|
|
||||||
|
@Resource |
||||||
|
private ApiProductService apiProductService; |
||||||
|
|
||||||
|
@Override |
||||||
|
@Transactional(rollbackFor=Exception.class,isolation = Isolation.SERIALIZABLE,propagation= Propagation.REQUIRES_NEW) |
||||||
|
public JSONObject createOrder(JSONObject object) { |
||||||
|
|
||||||
|
Map<String, Object> orderMap = new HashMap<>(); |
||||||
|
orderMap.put("sourceOrderNo" , object.getString("orderNo")); |
||||||
|
|
||||||
|
// 查询是否用重复订单
|
||||||
|
ApiOrderRecord apiOrderRecord = apiOrderRecordService.queryOrderResult(orderMap); |
||||||
|
|
||||||
|
ApiMerchants apiMerchants = apiMerchantsService.findByMchId(object.getString("merchId")); |
||||||
|
|
||||||
|
if (apiOrderRecord != null) { |
||||||
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.ORDER_ALREADY_EXISTS); |
||||||
|
} |
||||||
|
|
||||||
|
ApiProduct apiProduct = apiProductService.findById(object.getLong("goodsId")); |
||||||
|
// 当前账号余额是否可以充值当前金额
|
||||||
|
// if (apiMerchants.getAmounts().compareTo(apiProduct.))
|
||||||
|
|
||||||
|
|
||||||
|
return null; |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue