def un_liquidated_settlement_update(serial_number): try: s = Settlement.objects.get(pk=serial_number) s.status = SETTLEMENT_STATUS['FINISHED'] s.finished_datetime = timezone.now() s.save() except Settlement.DoesNotExist: return status.HTTP_400_BAD_REQUEST, { 'detail': f'serial_number {serial_number} dose not exist' } merchant_admin = MerchantAdmin.objects.filter(merchant_admin_type=MERCHANT_ADMIN_TYPES['ADMIN']) \ .filter(work_merchant__account__id=s.account_id).first() if merchant_admin: params = { "account_type": 'merchant', "openid": merchant_admin.wechat_openid, "content": { 'first': (TimeStampUtil.get_yesterday( s.datetime)).strftime('%Y年%m月%d日'), 'keyword1': fen_to_yuan_fixed_2(s.wechat_amount + s.alipay_amount), 'keyword2': s.finished_datetime.strftime('%Y年%m月%d日 %H:%M'), }, "template_type": 'merchant_settlement' # 结算账单消息 } push_template_message(params) return status.HTTP_200_OK, {'detail': 'ok'}
def audited_success(self, audited_date): params = { "account_type": 'merchant', "openid": self.merchant_admin.wechat_openid, "content": { 'pass_time': audited_date.strftime('%Y年%m月%d日 %H:%M'), }, "template_type": 'merchant_be_approved' # 被审核通过" } push_template_message(params)
def audited_fail(self, reason, audited_date): params = { "account_type": 'merchant', "openid": self.merchant_admin.wechat_openid, "content": { 'reason': f"{reason}" }, "template_type": 'merchant_not_be_approved' # 审核不通过" } push_template_message(params)
def wait_to_be_audit(self, merchant_name, commit_time): params = { "account_type": 'merchant', "openid": self.merchant_admin.wechat_openid, "content": { 'merchant_name': merchant_name, 'commit_time': commit_time.strftime('%Y年%m月%d日 %H:%M'), }, "template_type": 'merchant_commit_info' # 商户新增、信息修改" } push_template_message(params)
def inviter_marchant_audited(self, marketer_openid, audited_date): params = { "account_type": 'marketer', "openid": marketer_openid, "content": { 'merchant_name': self.merchant.name, 'pass_time': audited_date.strftime('%Y年%m月%d日 %H:%M'), }, "template_type": 'inviter_invite_merchant_pass' # 邀请的商户被审核通过" } push_template_message(params)
def salesman_marchant_audit(self, marketer_openid, apply_date): params = { "account_type": 'marketer', "openid": marketer_openid, "content": { 'applicant': self.merchant.name, 'apply_time': apply_date.strftime('%Y年%m月%d日 %H:%M'), }, "template_type": 'marketer_audit_merchant' # 新的商户需要被审核" } push_template_message(params)
def push_merchant_month_bill(request): year, month, bill_list = FinancialQuery.query_merchant_month_bill() time_str = f'{year}年{month}月' for merchant_bill in bill_list: merchant_bill['bill'].update({'bill_month': time_str, 'month': month}) temp_params = dict( account_type='merchant', # user, merchant, marketer openid=merchant_bill['open_id'], content=merchant_bill['bill'], template_type='merchant_month_bill', # 消息类型 ) push_template_message(temp_params) return JsonResponse({'result': 'OK'})
def on_pay_success(self, merchant_receive, payment_type, datetime, pay_serial_number): for user in self.merchant_admins: params = { "account_type": 'merchant', "openid": user.wechat_openid, "content": { 'first': '收款已到帐,可进入小程序查看详情', 'keyword1': payment_type, 'keyword2': merchant_receive, 'keyword3': datetime.strftime('%Y年%m月%d日 %H:%M'), 'serial_number': pay_serial_number, }, "template_type": 'merchant_receive' } push_template_message(params)
def on_refund_fail(self, refund_amount, refund_datetime, refund_serial_number): for user in self.merchant_admins: params = { "account_type": 'merchant', "openid": user.wechat_openid, "content": { 'first': '退款失败,请在小程序重新操作,或联系客服', 'keyword1': refund_serial_number, 'keyword2': refund_amount, 'keyword3': '失败', 'keyword4': refund_datetime.strftime('%Y年%m月%d日 %H:%M'), }, "template_type": 'merchant_refund_fail' # 消息类型" } push_template_message(params)
def on_refund_success(self, refund_amount, refund_datetime, refund_serial_number): for user in self.merchant_admins: params = { "account_type": 'merchant', "openid": user.wechat_openid, "content": { 'first': '账单已成功退款至用户', 'keyword1': refund_amount, 'keyword2': '已完成', 'keyword3': refund_datetime.strftime('%Y年%m月%d日 %H:%M'), 'remark': f'订单编号:{refund_serial_number}', 'serial_number': refund_serial_number }, "template_type": 'merchant_refund_success' # 消息类型" } push_template_message(params)