| | |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.core.context.IPageData; |
| | | import com.java110.core.context.PageData; |
| | | import com.java110.dto.app.AppDto; |
| | | import com.java110.dto.owner.OwnerAppUserDto; |
| | | import com.java110.dto.smallWeChat.SmallWeChatDto; |
| | | import com.java110.api.properties.WechatAuthProperties; |
| | | import com.java110.api.smo.AppAbstractComponentSMO; |
| | | import com.java110.api.smo.payment.IToPaySMO; |
| | | import com.java110.api.smo.payment.adapt.IPayAdapt; |
| | | import com.java110.core.context.IPageData; |
| | | import com.java110.core.context.PageData; |
| | | import com.java110.core.log.LoggerFactory; |
| | | import com.java110.dto.app.AppDto; |
| | | import com.java110.dto.owner.OwnerAppUserDto; |
| | | import com.java110.dto.smallWeChat.SmallWeChatDto; |
| | | import com.java110.utils.cache.MappingCache; |
| | | import com.java110.utils.constant.ServiceConstant; |
| | | import com.java110.utils.constant.CommonConstant; |
| | | import com.java110.utils.constant.WechatConstant; |
| | | import com.java110.utils.factory.ApplicationContextFactory; |
| | | import com.java110.utils.util.Assert; |
| | | import com.java110.utils.util.BeanConvertUtil; |
| | | import com.java110.utils.util.DateUtil; |
| | | import com.java110.utils.util.StringUtil; |
| | | import com.java110.vo.ResultVo; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.HttpMethod; |
| | | import org.springframework.http.HttpStatus; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | import java.util.UUID; |
| | | |
| | | @Service("toPaySMOImpl") |
| | | public class ToPaySMOImpl extends AppAbstractComponentSMO implements IToPaySMO { |
| | | private static final Logger logger = LoggerFactory.getLogger(AppAbstractComponentSMO.class); |
| | | |
| | | |
| | | |
| | | |
| | | @Autowired |
| | |
| | | @Override |
| | | protected ResponseEntity<String> doBusinessProcess(IPageData pd, JSONObject paramIn) throws Exception { |
| | | |
| | | ResponseEntity responseEntity = null; |
| | | ResponseEntity<String> responseEntity = null; |
| | | |
| | | SmallWeChatDto smallWeChatDto = getSmallWechat(pd, paramIn); |
| | | |
| | |
| | | String orderId = orderInfo.getString("oId"); |
| | | double money = Double.parseDouble(orderInfo.getString("receivedAmount")); |
| | | //需要判断金额是否 == 0 等于0 直接掉缴费通知接口 |
| | | |
| | | if (money <= 0) { |
| | | JSONObject paramOut = new JSONObject(); |
| | | paramOut.put("oId", orderId); |
| | | String urlOut = "fee.payFeeConfirm"; |
| | | responseEntity = this.callCenterService(getHeaders("-1", pd.getAppId()), paramOut.toJSONString(), urlOut, HttpMethod.POST); |
| | | JSONObject param = new JSONObject(); |
| | | if (responseEntity.getStatusCode() != HttpStatus.OK) { |
| | | param.put("code", "101"); |
| | | param.put("msg", "扣费为0回调失败"); |
| | | return new ResponseEntity(JSONObject.toJSONString(param), HttpStatus.OK); |
| | | } |
| | | JSONObject result = JSONObject.parseObject(responseEntity.getBody()); |
| | | if (ResultVo.CODE_OK != result.getInteger("code")) { |
| | | return responseEntity; |
| | | } |
| | | param.put("code", "100"); |
| | | param.put("msg", "扣费为0回调成功"); |
| | | return new ResponseEntity(JSONObject.toJSONString(param), HttpStatus.OK); |
| | | } |
| | | String appType = OwnerAppUserDto.APP_TYPE_WECHAT_MINA; |
| | | if (AppDto.WECHAT_OWNER_APP_ID.equals(pd.getAppId())) { |
| | | appType = OwnerAppUserDto.APP_TYPE_WECHAT; |
| | |
| | | return responseEntity; |
| | | } |
| | | |
| | | private Map<String, String> getHeaders(String userId, String appId) { |
| | | Map<String, String> headers = new HashMap<>(); |
| | | headers.put(CommonConstant.HTTP_APP_ID.toLowerCase(), appId); |
| | | headers.put(CommonConstant.HTTP_USER_ID.toLowerCase(), userId); |
| | | headers.put(CommonConstant.HTTP_TRANSACTION_ID.toLowerCase(), UUID.randomUUID().toString()); |
| | | headers.put(CommonConstant.HTTP_REQ_TIME.toLowerCase(), DateUtil.getDefaultFormateTimeString(new Date())); |
| | | headers.put(CommonConstant.HTTP_SIGN.toLowerCase(), ""); |
| | | return headers; |
| | | } |
| | | |
| | | private SmallWeChatDto getSmallWechat(IPageData pd, JSONObject paramIn) { |
| | | |
| | |
| | | pd.getAppId()); |
| | | responseEntity = this.callCenterService(restTemplate, pd, "", |
| | | "smallWeChat.listSmallWeChats?appId=" |
| | | + paramIn.getString("appId") + "&page=1&row=1&communityId="+paramIn.getString("communityId"), HttpMethod.GET); |
| | | + paramIn.getString("appId") + "&page=1&row=1&communityId=" + paramIn.getString("communityId"), HttpMethod.GET); |
| | | |
| | | if (responseEntity.getStatusCode() != HttpStatus.OK) { |
| | | return null; |