做網(wǎng)站是什么鬼做國外網(wǎng)站
目錄
- 上下架功能提供
- 后臺寵物列表實現(xiàn)
- 前臺展示
- 前臺寵物列表和詳情展示
- 店鋪展示
- 領養(yǎng)
- 分析
- 前臺
- 后端
- PetController
- PetServiceImpl
- 訂單
- 需求分析
- 可能產(chǎn)生訂單的模塊
- 訂單模塊額外功能
- 訂單設計
- 表設計
- 流程設計
- 集成基礎代碼
- 收購訂單
- 創(chuàng)建訂單
- 前端
- 后端
上下架功能提供
后臺寵物列表實現(xiàn)
后端:拷貝product模塊,替換大小寫字母,調(diào)整字段名,時間顯示格式等,
后臺:拷貝資源中的pet.vue,配置路由,調(diào)整變量名,
前臺展示
前臺寵物列表和詳情展示
前臺拷貝product.html為pet.html,替換大小寫字母,首頁跳轉(zhuǎn)過來,pet能跳轉(zhuǎn)其他,
前臺拷貝productDetail.html為petDetail.html,替換大小寫字母,改預定須知為領養(yǎng)須知,
修改后端loadById查詳情sql,前端取店名展示
<resultMap id="petMap" type="Pet"><id property="id" column="id"></id><result property="name" column="name"></result><result property="resources" column="resources"></result><result property="saleprice" column="saleprice"></result><result property="costprice" column="costprice"></result><result property="offsaletime" column="offsaletime"></result><result property="onsaletime" column="onsaletime"></result><result property="state" column="state"></result><result property="createtime" column="createtime"></result><!--private PetDetail detail = new PetDetail();--><association property="detail" javaType="PetDetail"><id property="id" column="pdid"></id><result property="intro" column="intro"></result><result property="adoptNotice" column="adoptNotice"></result></association><association property="shop" javaType="Shop"><id property="id" column="sid"></id><result property="name" column="sname"></result></association></resultMap><select id="loadById" parameterType="long" resultMap="petMap">selectp.*,pd.id pdid,pd.intro,pd.adoptNotice,s.id sid,s.name snamefrom t_pet pLEFT JOIN t_pet_detail pd on p.id = pd.pet_idLEFT join t_shop s on p.shop_id = s.idwhere p.id = #{id}</select>
<!--名稱--><div class="tb-detail-hd"><h1>【{{pet.shop.name}}】 {{pet.name}}</h1></div>
店鋪展示
petDetail頁面的大包裝右邊展示店鋪名稱
通過:href="shopUrl"攜帶shopid跳往shop頁面
<li class="qc last"><a :href="shopUrl" style="color: green">{{pet.shop.name}}</a></li>
shopUrl:"",
mounted(){let petId = parseUrlParams2Obj(location.href).petId;this.$http.get("/pet/"+petId).then(result=>{this.pet = result.data;if(this.pet.resources){this.resources = this.pet.resources.split(',');}this.shopUrl = "shop.html?shopId="+this.pet.shop.id;}).catch(result=>{console.log(result);alert("系統(tǒng)錯誤");})}
拷貝success頁面為shop頁面,替換引入路徑,修改標題,引入vue和Axios,
寫個div把body以內(nèi)全包起來,發(fā)請求拿shop數(shù)據(jù)過來展示,
<script type="text/javascript">new Vue({el:"#myShop",data:{shop:{}},methods:{getShop(){let shopId = parseUrlParams2Obj(location.href).shopId;this.$http.get("/shop/"+shopId).then(result=>{this.shop = result.data;$("#myTitle").html(this.shop.name);//自己去yyy}).catch(result=>{console.log(result);alert("系統(tǒng)錯誤");})}},mounted(){this.getShop();}})</script>
領養(yǎng)
分析
領養(yǎng)即購買,立即領養(yǎng)進入領養(yǎng)流程,購物車可通過加一個表實現(xiàn)(包含userid和寵物信息),
點擊立即購買后流程:
傳入寵物信息,修改為下架,綁定購買者userid,生成訂單和支付(這兩個放到后面)
前臺
petDetail頁面把立即購買包進div里,
立即購買超鏈接綁定事件,發(fā)請求到后端進入處理流程,(擴展:處理完后進入個人中心-我的領養(yǎng) 展示寵物表中userId是自己的)
<a id="LikBuy" title="點此按鈕到下一步確認購買信息" href="javascript:;" @click="adopt">立即購買</a>
adopt(){let petId = this.pet.id;let flag = window.confirm("你確認領養(yǎng)嗎?")if(flag){this.$http.get("/pet/adopt/"+petId).then(result=>{result = result.data;if(result.success){alert("領養(yǎng)成功!");//本來應該跳轉(zhuǎn)到個人中心,查案個人領養(yǎng)寵物信息//這里我們就跳轉(zhuǎn)到首頁location.href="index.html";}else{alert(result.message);}}).catch(result=>{alert("系統(tǒng)錯誤");})}//location.href="adoptOrder.html?petId="+this.pet.id;}
后端
PetController
/*** 領養(yǎng)寵物*/@GetMapping("/adopt/{petId}")public AjaxResult adopt(@PathVariable("petId") Long petId, HttpServletRequest request){try {Logininfo loginIn = LoginContext.getLoginIn(request);petService.adopt(petId,loginIn.getId());return AjaxResult.me();} catch (Exception e) {e.printStackTrace();return AjaxResult.me().setMessage("領養(yǎng)失敗!"+e.getMessage());}}
PetServiceImpl
@Overridepublic void adopt(Long petId, Long loginInfoId) {//1.修改狀態(tài) 下架Pet pet = petMapper.loadById(petId);pet.setState(0);pet.setOffsaletime(new Date());//2.綁定用戶User user = userMapper.loadByloginInfoId(loginInfoId);pet.setUser(user);pet.setUser_id(user.getId());pet.setShop_id(pet.getShop().getId());//3.保存petMapper.update(pet);//@TODO 生成領養(yǎng)訂單 + 支付System.out.println("領養(yǎng)成功!");}
訂單
需求分析
可能產(chǎn)生訂單的模塊
1.寵物收購訂單-店家給用戶錢
墊付:用戶立馬就能獲取到錢,員工定時報賬。
余額支付:付款余額,用戶可以提現(xiàn)。 平臺相當于給了用戶錢,店家用給平臺錢。
銀行轉(zhuǎn)賬:銀行轉(zhuǎn)賬,店家財務依次給用戶轉(zhuǎn)賬。
2.服務訂單(多次消費)-用戶給店家錢
3.領養(yǎng)訂單(一次)-用戶給店家錢
4.充值訂單(一次)-用戶充值平臺,用戶消費后,平臺要給店鋪打錢。
5.商品訂單(多次)-用戶給店家錢
特別說明一下:
大平臺一般錢先到平臺,用戶確認后,平臺才劃賬到店家。如果用戶長時間不確認,自動確認。
我們小平臺直接到店家,我們沒有支付牌照。
每一類型的訂單都要有獨立的表來存
訂單模塊額外功能
1.系統(tǒng)報表、財務報表等
2.商家的賬單下載(easyPOI的導入與導出)
3.系統(tǒng)對賬服務(退款,支付異常等)
4.30分鐘未支付取消訂單(定時器)
訂單設計
表設計
九張: 用戶地址 訂單地址 收購訂單 領養(yǎng)訂單 充值訂單 商品訂單 商品訂單詳情 服務訂單 服務訂單詳情
我們需要關心的五張表:
t_user_address:用戶地址,
t_order_address:訂單地址,下單時的用戶地址,綁定某個訂單
t_order_pet_acquisition:收購訂單,一次性,不需要存詳情
t_order_adopt:領養(yǎng)訂單,一次性,不需要存詳情
t_order_product:服務訂單,可多次消費,需要存詳情
流程設計
用戶付錢給商家,兩個定時任務
商家付款給用戶(收購訂單)
工作人員上門,應該帶一個手提電腦,處理完并下單。以后需要商家版App,可以在上面操作,不需要手提電腦。
集成基礎代碼
拷貝資源
收購訂單
創(chuàng)建訂單
前端
待處理消息處理窗口增加支付選項下拉框
后端
SearchMasterMsgController
/*** 處理消息*/@PutMapping("/handle")public AjaxResult handle(@RequestBody Pet pet,HttpServletRequest request){try {Logininfo loginIn = LoginContext.getLoginIn(request);seachMasterMsgService.handle(pet,loginIn.getId());return AjaxResult.me();} catch (Exception e) {e.printStackTrace();return AjaxResult.me().setMessage("處理失敗!"+e.getMessage());}}
SearchMasterMsgServiceImpl
/*** 處理消息*/@Overridepublic void handle(Pet pet,Long loginInfoId) {//1.改狀態(tài) --已處理searchMasterMsgMapper.updateStateForProcessed(pet.getSearch_master_msg_id());//2.生成寵物基本信息petMapper.save(pet);//3.寵物詳情PetDetail detail = pet.getDetail();if(detail != null){detail.setPet_id(pet.getId());petDetailMapper.save(detail);}//4.生成訂單Employee employee = employeeMapper.loadByLoginInfoId(loginInfoId);SearchMasterMsg searchMasterMsg = searchMasterMsgMapper.loadById(pet.getSearch_master_msg_id());PetAcquisitionOrder order = pet2order(pet, searchMasterMsg, employee.getId());petAcquisitionOrderMapper.save(order);//5.生成支付@TODO}private PetAcquisitionOrder pet2order(Pet pet, SearchMasterMsg adopt,Long employeeId) {PetAcquisitionOrder order = new PetAcquisitionOrder();order.setDigest("[摘要]對"+pet.getName()+"收購訂單!");order.setState(0);//待支付order.setPrice(pet.getCostprice());order.setAddress(adopt.getAddress());String orderSn = CodeGenerateUtils.generateOrderSn(adopt.getUser_id());order.setOrderSn(orderSn);order.setPet_id(pet.getId());order.setUser_id(adopt.getUser_id());order.setPaytype(0);order.setShop_id(pet.getShop_id());order.setEmp_id(employeeId);return order;}