package com.weiit.web.api.controller;
import com.github.binarywang.wxpay.util.SignUtils;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.weiit.core.entity.E;
import com.weiit.core.entity.FormMap;
import com.weiit.resource.common.utils.RedisUtil;
import com.weiit.resource.common.utils.WeiitUtil;
import com.weiit.web.api.service.*;
import com.weiit.web.base.FrontController;
import com.weiit.web.common.ApiResponseCode;
import com.weiit.web.common.Constants;
import com.weiit.web.common.RedisKey;
import com.weiit.web.util.DateUtil;
import com.weiit.web.weixinopen.util.XMLUtil;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.math.RandomUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import java.io.IOException;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.*;
/**
* 订单接口
*
* @author tangjian
* @version 1.0
* @date:2018年5月7日 上午2:01:43
* @company http://www.wei-it.com
*/
@Controller
@RequestMapping(value = "/api/order")
public class OrderController extends FrontController {
@Resource
private OrderService orderService;
@Resource
UserService userService;
@Resource
PlatformService platformService;
@Resource
ProductService productService;
@Resource
RedisUtil redisUtil;
@Resource
MessageService messageService;
@Resource
IntegralService integralService;
/**
* 订单确认接口
*
* @return
* @throws Exception
* 参数有cart_ids,address_id,payment_type,remark,express_type,express_money, coupon_id(用户优惠券表的id) 优惠券ID ,pay_price
*/
@ResponseBody
@RequestMapping(value = "/addOrder", method = RequestMethod.POST)
public String addOrder(@RequestHeader("token") String token) throws Exception {
logger.info("【商品】提交订单,orderController-addOrder");
FormMap formMap = getFormMap();
if (formMap.get("user_id") != null) {
//核对订单信息,重新计算总额
double sum = 0;
double payPrice = 0;
List<E> cartList = orderService.selectUserCartList(formMap);
if (cartList == null && cartList.size()==0) {
return toJsonAPI("", "创建订单失败,购物车为空", "1006");
}
for (E cart : cartList) {
sum = sum + cart.getDouble("smarket_price") * cart.getInt("count");
payPrice = payPrice + cart.getDouble("sale_price") * cart.getInt("count");
}
formMap.put("order_num", Constants.ORDER_SHOP + System.currentTimeMillis() + StringUtils.leftPad(formMap.getStr("user_id"), 8, RandomUtils.nextInt(1000000) + ""));
formMap.put("total_price", sum);
//计算优惠金额
double coupon_price =0.0;
//表示有优惠券抵扣 小程序传undifined
if(!StringUtils.isEmpty(formMap.getStr("coupon_id")) && !formMap.getStr("coupon_id").equals("undefined")){
E coupon=orderService.selectUserCouponById(formMap);
if (coupon==null){
return toJsonAPI("", "创建订单失败,优惠券不在使用时间", "1005");
}else if(coupon.getInt("state")==-1){
return toJsonAPI("", "创建订单失败,优惠券已过期", "1005");
}else if(coupon.getInt("state")==1){
return toJsonAPI("", "创建订单失败,优惠券已使用", "1005");
}
//都是可用优惠券 不用判断 无条件或是满减
//通用商品 若有售后问题打包退回
if (coupon.getInt("product_range_type")==1){
//指定金额
if(coupon.getInt("type")==1){
coupon_price=coupon.getDouble("coupon_price");
for (E cart : cartList) {
//销售金额 -优惠金额*(销售金额/支付金额)= 商品的实际支付金额(售后的退款金额)
double salePrice = cart.getDouble("sale_price") * cart.getInt("count");
cart.set("coupon_pay",salePrice-calcPayPrice(salePrice,payPrice,coupon_price));
cart.set("pay_price",calcPayPrice(salePrice,payPrice,coupon_price));
}
}
//打折
else if(coupon.getInt("type")==2) {
coupon_price= getDoubleValue(new BigDecimal(payPrice).multiply(new BigDecimal(10).subtract(new BigDecimal(coupon.getStr("coupon_discount"))).divide(new BigDecimal(10))));
for (E cart : cartList) {
//销售金额 -优惠金额*(销售金额/支付金额)= 商品的实际支付金额(售后的退款金额)
double salePrice = cart.getDouble("sale_price") * cart.getInt("count");
cart.set("coupon_pay",getDoubleValue(new BigDecimal(salePrice).multiply(new BigDecimal(10-coupon.getInt("coupon_discount"))).divide(new BigDecimal(10))));
cart.set("pay_price",getDoubleValue(new BigDecimal(salePrice).multiply(new BigDecimal(coupon.getInt("coupon_discount"))).divide(new BigDecimal(10))));
}
}
}//指定商品
else if (coupon.getInt("product_range_type")==2){
String [] product_ids = coupon.getStr("product_ids").split(",");
//指定金额
boolean flag = false;
if(coupon.getInt("type")==1){
coupon_price=coupon.getDouble("coupon_price");
for(String productId:product_ids){
for (E cart : cartList) {
if (cart.getStr("product_id").equals(productId)){
//
cart.set("coupon_pay",coupon_price);
//未测精度缺失
cart.set("pay_price",cart.getDouble("sale_price") * cart.getInt("count")-coupon_price);
flag=true;
break;
}
}
if (flag){
break;
}
}
}else if(coupon.getInt("type")==2) {//打折
double temp_price =0.0;
for(String productId:product_ids){
for (E cart : cartList) {
if (cart.getStr("product_id").equals(productId)){
temp_price+=cart.getDouble("sale_price") * cart.getInt("count");
//该件商品的支付金额 方便售后退货
cart.set("coupon_pay",getDoubleValue(new BigDecimal(cart.getDouble("sale_price") * cart.getInt("count")).multiply(new BigDecimal(10-coupon.getInt("coupon_discount")).divide(new BigDecimal(10)))));
cart.set("pay_price",getDoubleValue(new BigDecimal(cart.getDouble("sale_price") * cart.getInt("count")).multiply(new BigDecimal(coupon.getInt("coupon_discount")).divide(new BigDecimal(10)))));
}
}
}
coup
没有合适的资源?快使用搜索试试~ 我知道了~
SaaS微信小程序电商系统一键生成小程序源码
共2000个文件
png:1271个
js:497个
java:402个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
5星 · 超过95%的资源 1 下载量 89 浏览量
2022-06-15
11:31:41
上传
评论 1
收藏 36.74MB ZIP 举报
温馨提示
采用Spring+SpringMVC+Mybatis主流开源框架,遵循MVC架构,设计轻巧,使用简单,开发人员接手与二次开发简单易懂;项目依赖的核心支持jar包,都已经完全开源. 项目完成了对阿里云、腾讯云、微信生态的快速接入与代码示例,并成功运用到了商业中,方便大家学习对OSS/COS/短信服务/快递服务/公众号/小程序/微信开放平台/微信支付的技术点与应用场景的学习。小程序与公众号第三方授权集成,让开发者与企业省去繁琐的配置,对AppId/AppSecret集成彻底告别。微信支付第三方授权集成,让开发者与企业省去繁琐的配置,让企业服务成本大大降低。小程序代码自动push与升级,公众号基本常规功能(自定义菜单、图文、素材,群发)全部接管,让企业无需登录微信官方入口,统一化管理企业信息与数据。微信消息通知与模板自动同步与管理,让企业场景融合无障碍。像淘宝装修一样的自定义装修功能,实现企业电商场景多元化,解决不同行业不同模板,让企业需求得到真正解决。丰富的营销工具,解决企业微营销需求,并集中化管理。拼团活动、积分活动、砍价活动等等,方便二次开发。不同企业数据隔离,真正实现SAAS数据隔离
资源推荐
资源详情
资源评论
收起资源包目录
SaaS微信小程序电商系统一键生成小程序源码 (2000个子文件)
.babelrc 435B
.babelrc 230B
components.min.css 328KB
components.min.css 328KB
index.css 193KB
bootstrap.min.css 119KB
bootstrap.min.css 119KB
core.min.css 118KB
core.min.css 118KB
login.min.css 111KB
login.min.css 111KB
neditor.css 72KB
neditor.css 72KB
neditor.min.css 58KB
neditor.min.css 58KB
styles.css 47KB
styles.css 47KB
iconfont.css 43KB
colors.min.css 37KB
colors.min.css 37KB
jquery-ui.min.css 31KB
font-awesome.min.css 30KB
buttoniconex.css 25KB
buttoniconex.css 25KB
styles.min.css 23KB
styles.min.css 23KB
video-js.css 21KB
video-js.css 21KB
image.css 19KB
image.css 19KB
video.css 15KB
video.css 15KB
attachment.css 14KB
attachment.css 14KB
video-js.min.css 11KB
video-js.min.css 11KB
menu.css 8KB
menu.css 8KB
main.css 8KB
main.css 8KB
style.css 8KB
shCoreDefault.css 7KB
shCoreDefault.css 7KB
demo.css 6KB
demo.css 6KB
iconfont.css 6KB
scrawl.css 6KB
scrawl.css 6KB
reset.css 5KB
reset.css 5KB
validationEngine.jquery.css 4KB
validationEngine.jquery.css 4KB
index.css 4KB
login.css 4KB
jquery.pagewalkthrough.css 3KB
codemirror.css 3KB
codemirror.css 3KB
reset.css 3KB
music.css 3KB
music.css 3KB
charts.css 3KB
charts.css 3KB
background.css 3KB
background.css 3KB
wangEditor-1.1.0-min.css 2KB
user.css 2KB
user.css 2KB
dialogbase.css 2KB
dialogbase.css 2KB
emotion.css 2KB
emotion.css 2KB
edittable.css 1KB
edittable.css 1KB
template.css 1KB
template.css 1KB
webuploader.css 515B
webuploader.css 515B
help.css 389B
help.css 389B
iframe.css 87B
iframe.css 87B
.editorconfig 147B
.editorconfig 147B
icomoon.eot 213KB
icomoon.eot 213KB
fontawesome-webfont.eot 59KB
fontawesome-webfont.eot 59KB
iconfont.eot 43KB
iconfont.eot 25KB
iconfont.eot 25KB
iconfont.eot 25KB
iconfont.eot 25KB
glyphicons-halflings-regular.eot 20KB
glyphicons-halflings-regular.eot 20KB
iconfont.eot 5KB
vjs.eot 3KB
vjs.eot 3KB
.eslintrc 97B
UEditorSnapscreen.exe 508KB
UEditorSnapscreen.exe 508KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
- tomhonsom752022-08-09资源质量不错,和资源描述一致,内容详细,对我很有用。
办公模板库素材蛙
- 粉丝: 1536
- 资源: 2286
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Screenshot_2024-04-20-16-26-41-628_com.tencent.mm-edit.jpg
- QT界面+FFMPEG 做解码库实现播放流媒体以及本地视频+可叠加透明视频+源码(毕业设计&课程设计&项目开发)
- 基于opencv的停车场空余车位实时监测系统(源码)
- KUKA机器人基本指令的使用
- 基于Qt+c++实现的仿Linux锁屏界面+源码+文档(毕业设计&课程设计&项目开发)
- 基于Qt+c++实现的简易光线追踪渲染器适合小白入手学习+源码+文档(毕业设计&课程设计&项目开发)
- C语言操作系统实验代码
- 基于Qt+c++开发的仿网易云桌面端的音乐播放器+源码+文档(毕业设计&课程设计&项目开发)
- 动态数码管0.0~9.9计数(普中单片机)
- py源码实例excel处理实例多工作表合并到单工作表
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功