123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- package com.lightinit.hsdataportal.impl;
- import com.lightinit.hsdataportal.dictionary.DicOrderState;
- import com.lightinit.hsdataportal.entity.Order;
- import com.lightinit.hsdataportal.entity.OrderExample;
- import com.lightinit.hsdataportal.entity.UserAccount;
- import com.lightinit.hsdataportal.mapper.OrderMapper;
- import com.lightinit.hsdataportal.mapper.UserAccountMapper;
- import com.lightinit.hsdataportal.model.ResultState;
- import com.lightinit.hsdataportal.model.ResultStateCode;
- import com.lightinit.hsdataportal.service.IAlipayService;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import org.springframework.transaction.annotation.Transactional;
- import org.springframework.transaction.interceptor.TransactionAspectSupport;
- import java.util.Date;
- import java.util.List;
- @Service
- public class AlipayServiceImpl implements IAlipayService {
- @Autowired
- private OrderMapper orderMapper;
- @Autowired
- private UserAccountMapper userAccountMapper;
-
- @Override
- public Order queryUserOrderByOrderNumber(String orderNumber) {
- OrderExample bizOrderExample = new OrderExample();
- bizOrderExample.createCriteria().andOrderNumberEqualTo(orderNumber);
- List<Order> list = orderMapper.selectByExample(bizOrderExample);
- if(list==null||list.size()!=1){
- return null;
- }
- return list.get(0);
- }
- @Override
- public ResultState<String> updateUserOderByOrderNumber(Long id, String orderNumber) {
- ResultState<String> resultState = new ResultState<>();
- try {
- Order order = new Order();
- order.setId(id);
- order.setOrderState(DicOrderState.PAY_SUCCESS);
- orderMapper.updateByPrimaryKeySelective(order);
-
- Order order1 = orderMapper.selectBusinessType(orderNumber);
- if("账户充值".equals(order1.getBusinessType())) {
- UserAccount userAccount = new UserAccount();
- UserAccount userAccount1 = userAccountMapper.selectByPrimaryKey(order1.getUserId());
- if(userAccount1==null) {
- userAccount.setBalance(order1.getOrderAmount());
- userAccountMapper.insert(userAccount);
- }
- userAccount.setBalance(userAccount1.getBalance().add(order1.getOrderAmount()));
- userAccountMapper.updateByPrimaryKeySelective(userAccount);
- }
- resultState.setData(orderNumber);
- return resultState;
- } catch (Exception e) {
- e.printStackTrace();
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
- }
- resultState.setStateCode(ResultStateCode.DB_ERROR);
- resultState.setMsg("biz_order数据库‘支付成功’修改失败,请手动修改id="+id+",或者订单号是:"+orderNumber);
- return resultState;
- }
-
- }
|